package hjw.com.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * <p>Project:Academic - DateUtil
 *
 * @author IvanWei玮 -- maste
 * @version 1.0
 * @DataTime 2025/2/19 3:14
 * @since 1.8
 */
public class DateUtil {

    public static Date getDieDate(int day){
        // 格式化日期通用对象
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH,-day);
        Date dieDate = calendar.getTime();
        String xDaysLaterStr = sdf.format(dieDate);
        System.out.println(xDaysLaterStr);
        return dieDate;
    }
    public static String getDieDay(int day){
        // 格式化日期通用对象
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH,-day);
        Date dieDate = calendar.getTime();
        String xDaysLaterStr = sdf.format(dieDate);
        System.out.println(xDaysLaterStr);
        return xDaysLaterStr;
    }
}
